package WaiBao;

import java.util.Arrays;

public class JiaHuiQiang {
    public static void main(String[] args) {
        String[] name = {"队长(班长)", "西柚(副班长)", "小李(学习委员)", "程佳佳(体育委员)", "王子文", "张瑞瑞", "李思文", "小寻", "王瑞瑞", "贾探春", "李小彪", "王海",
                "杜海涛", "唐悠悠", "小晗", "王传君", "李凯子", "小愈", "沈腾", "王涛涛", "徐峥", "小白", "小修", "李小龙", "黄碧", "小颇", "小恬", "黄渤",
                "陈美嘉", "贾慧强(学生)"};//考生本人:贾慧强(学生)
        int[] age = {19, 18, 17, 18, 21, 20, 22, 20, 19,20, 18, 18, 20, 21, 20, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 19, 20, 21, 19};//考生年龄19

        double[] mengyu1 = {73, 76, 84, 70, 79, 67, 78, 80, 85, 80, 81, 87, 85, 89, 85, 65, 99, 99, 96, 88, 92, 91, 95, 65, 85, 74, 91, 84, 87, 95};
        double[] mengyu2 = {96, 85, 64, 76, 75, 87, 74, 69, 74, 70, 91, 77, 76, 95, 64, 65, 76, 99, 66, 98, 72, 71, 95, 96, 76, 86, 84, 88, 77, 95};
        double[] mengyu3 = {80, 75, 84, 85, 77, 66, 78, 64, 80, 80, 63, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 79, 78, 89, 96};


        double yingxue1;//代表每个学生的总分
        double yingxue2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            yingxue1 = mengyu1[i] + mengyu2[i] + mengyu3[i];
//            yingxue2 = (yingxue1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + yingxue1);
//            System.out.println(name[i] + "的平均分为:" + yingxue2);
//        }


//        double pu1 = 0, pu2 = 0;
//        double[] tong = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pu1= mengyu1[i] +mengyu2[i] + mengyu3[i];
//            pu2 = (pu1 * 1.0) / 3;
//            tong[i] = pu2;
//        }
//
//        for (int i = 0; i < tong.length - 1; i++) {
//            for (int j = 0; j < tong.length - i - 1; j++) {
//                if (tong[j] < tong[j + 1]) {
//                    double tep =tong[j];
//                    tong[j] =tong[j + 1];
//                    tong[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(tong[i]);
//        }


        double peini1 = 0,  peini2 = 0,  peini3 = 0;//计算每门课的平均分
        double duguo1 = 0, duguo2 = 0, duguo3 = 0;//计算每门课标准差
        double manch1 = 0, manch2 = 0, manch3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <mengyu1.length; i++) {
            he += mengyu1[i];
        }
        peini1 = (he * 1.0) / 30;
        System.out.println("分析化学的班级平均分为:" +  peini1);
        double Sum = 0;
        for (int i = 0; i < mengyu2.length; i++) {
            Sum +=mengyu2[i];
        }
        peini2 = (Sum * 1.0) / 30;
        System.out.println("线性代数的班级平均分为:" + peini2);
        double sum = 0;
        for (int i = 0; i < mengyu3.length; i++) {
            sum +=mengyu3[i];
        }
        peini3 = (sum * 1.0) / 30;
        System.out.println("有机化学的班级平均分为:" +  peini3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <mengyu1.length; i++) {
            c1 += (mengyu1[i] - peini1) * (mengyu1[i] - peini1);
        }
        duguo1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:" +duguo1);
        for (int i = 0; i < mengyu2.length; i++) {
            c2 += (mengyu2[i] -  peini2) * (mengyu2[i] - peini2);
        }
        duguo2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:" + duguo2);

        for (int i = 0; i < mengyu3.length; i++) {
            c3 += (mengyu3[i] - peini3) * (mengyu3[i] -  peini3);
        }
        duguo3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:" + duguo3);
//////
////
////
        Arrays.sort(mengyu1);
        Arrays.sort(mengyu2);
        Arrays.sort(mengyu3);
        manch1 = (mengyu1[14] + mengyu2[15]) * 1.0 / 2;
        manch2 = (mengyu2[14] + mengyu2[15]) * 1.0 / 2;
        manch3 = (mengyu3[14] + mengyu3[15]) * 1.0 / 2;
        System.out.println("分析化学的中位数为:" + manch1);
        System.out.println("线性代数的中位数为:" + manch2);
        System.out.println("有机化学的中位数为:" + manch3);



    }
}
